package com.qzsf.backend.mapper;

import com.qzsf.backend.entity.EventType;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/10/30 20:23 周三
 * @Email 1429278462@qq.com
 * @Remark 活动类型数据访问层
 * @Version 1.0
 */
@Mapper
@Repository
public interface EventTypeMapper {
    @Select("select * from event_type")
    List<EventType> getAllEventTypes();

    @Insert("insert into event_type (type, description) VALUES (#{type},#{description})")
    int createEventType(EventType eventType);

    @Update("update event_type set type = #{type},description = #{description} where id = #{id}")
    int updateEventType(EventType eventType);

    @Delete("delete from event_type where id = #{id}")
    int deleteEventType(int id);

    @Select("select * from event_type where id = #{id}")
    EventType getEventTypeById(int id);

    @Select("select * from event_type where type like concat('%',#{type},'%')")
    List<EventType> getEventByName(String type);
}
